package com.gitzzp.testtinker;

import android.os.Bundle;
import android.os.Environment;
import android.os.Process;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import com.tencent.tinker.lib.tinker.Tinker;
import com.tencent.tinker.lib.tinker.TinkerInstaller;
import com.tencent.tinker.loader.shareutil.ShareTinkerInternals;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);



    }

    @Override
    protected void onResume() {
        super.onResume();
        //接收patch
        TinkerInstaller.onReceiveUpgradePatch(getApplicationContext(), Environment.getExternalStorageDirectory().getAbsolutePath()+"/patch_signed_7zip.apk");
//        Toast.makeText(this, "base apk", Toast.LENGTH_SHORT).show();
        Toast.makeText(this, "this is a patch", Toast.LENGTH_SHORT).show();
    }

    private void tinker(){
        //部分功能说明

        //接收patch
        TinkerInstaller.onReceiveUpgradePatch(getApplicationContext(),"patch路径");

        //clear patch
        Tinker.with(getApplicationContext()).cleanPatch();

        //杀死程序
        ShareTinkerInternals.killAllOtherProcess(getApplicationContext());
        Process.killProcess(Process.myPid());

    }
}
